package com.itheima.d3_time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFormatTest {
    public static void main(String[] args) throws ParseException {
        // 掌握simpleDateFormat
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(new Date()));


        // 1. 准备一些日期
        Date date = new Date();
        System.out.println(date);

        long time = date.getTime();
        System.out.println(time);

        // 2 格式化日期对象 和时间毫秒值
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dateStr = "2022-12-12 12:12:12";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf2.format(date));
        System.out.println(sdf2.parse(dateStr));


    }
}
